home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Controls
/
Visual Basic Controls.iso
/
vbcontrol
/
asppw112
/
fdattr.asp
< prev
next >
Wrap
Text File
|
1999-01-07
|
3KB
|
111 lines
<HTML><BODY>
<%
' GetFDAttr(ByVal vsPathName As String) As Integer
' output: >=0 File/Dir attribute
' -1 Failure
' SetFDAttr(ByVal vsPathName As String, ByVal vnAttr As Integer) As Integer
' output: 1 Succeed
' -1 Failure
' Sample Operation:
' Toggle system bit of a file in virtual directory of "/".
'
'
'
' This file is provided as part of ASP Power Widgets Samples
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
' OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
' PURPOSE.
' Copyright 1997-1998. All rights reserved.
' Dalun Software Inc. ASP Power Widgets
' http://www.dalun.com
' http://members.tripod.com/ActiveServerPage/
vbNormal = 0 'Normal
vbReadOnly = 1 'Read-only
vbHidden = 2 'Hidden
vbSystem = 4 'System
vbDirectory = 16 'Directory or folder
vbArchive = 32 'File has changed since last backup
sDirName = Server.MapPath("/")
response.write "<p><h2>File/Directory Attribute Demo.</h2></p>"
Set oFDMgt = Server.CreateObject("ASPPW.FDMgt")
if oFDMgt.ReadDir(sDirName)= -1 then
response.write "Read Directory Action Failed.<br>"
response.write oFDMgt.GetLastErrDescription
else
Set oFilelist = ofdmgt.Files
if oFilelist.count =0 then
response.write "Demo cann't proceed since there is no file in " & sDirName & "."
else
set file=oFilelist.Item(1)
sAttr=""
nAttr=ofdmgt.GetFDAttr( sDirName & "\" & file.name) 'Demo !!!
if nAttr And vbReadOnly then
sAttr=sAttr & "R "
end if
if nAttr And vbHidden then
sAttr=sAttr & "H "
end if
if nAttr And vbSystem then
sAttr=sAttr & "S "
end if
if nAttr And vbArchive then
sAttr=sAttr & "A "
end if
if sAttr="" then
sAttr="----<br>"
end if
response.write "<font size=2 face=""Courier New"">" & file.Name & " attribute is: " & sAttr & "</font><br>"
response.write "Now change its attribute bit of <u>System</u><br>"
nAttr = nAttr xor vbSystem
iReturnCode=ofdmgt.SetFDAttr( sDirName & "\" & file.name, nAttr) 'Demo !!!
if iReturnCode = 1 then
response.write "Setting attribute succeeded.<br>"
sAttr=""
nAttr=ofdmgt.GetFDAttr( sDirName & "\" & file.name) 'Demo !!!
if nAttr And vbReadOnly then
sAttr=sAttr & "R "
end if
if nAttr And vbHidden then
sAttr=sAttr & "H "
end if
if nAttr And vbSystem then
sAttr=sAttr & "S "
end if
if nAttr And vbArchive then
sAttr=sAttr & "A "
end if
if sAttr="" then
sAttr="----<br>"
end if
response.write "<font size=2 face=""Courier New"">" & file.Name & " attribute is: " & sAttr & "</font><br>"
else
response.write "Setting attribute failed. " & oFDMgt.GetLastErrDescription
end if
end if
Set oFilelist=nothing
end if
Set oFDMgt = Nothing
%>
</BODY></HTML>